home *** CD-ROM | disk | FTP | other *** search
/ Sun Solutions 2000 #2 / Sun Solutions CD (Volume 2 2000)(Special Focus - Java Technologies)(Disc 1).ISO / products / Software / UniTrendsSoftwareCorporation / _install / launchit.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2000-04-03  |  6KB  |  249 lines

  1. #!/bin/sh 
  2. if [ "$HOME" = "" ]; then
  3.         HOME="/"; export HOME
  4. fi
  5. #
  6. # Generic launch script for use with MDSS cdrom mechanism 
  7. #
  8. # marc.sacoolas@sun.com 
  9. #
  10. #**********************
  11. #     Begin subs
  12. #**********************
  13.  
  14. # Check if user wants to be root 
  15. check_root_maybe() {
  16. if [ "$USER" != "root" ]; then
  17.   while true
  18.   do
  19.     echo ""
  20.     echo "You may need to be root user to install this software in certain directories. \c"
  21.     echo ""
  22.     echo "Would you like to become root user? <[y/n] n> \c"
  23.     read ans
  24.      if [ "$ans" = "" ]; then 
  25.     ans="n" 
  26.      fi
  27.  
  28.      case "$ans" in
  29.       y|Y|yes|YES) echo "";echo "Enter super user \c";su root -c 'USER=root;export USER;$COMPANY_DIR/_install/launchit.sh $theARGS';exit 0
  30.             ;;
  31.       N|Q|n|q|No|quit|NO|QUIT|Quit) break 
  32.             ;;
  33.      esac
  34.   done
  35. fi 
  36. }
  37. # Check if root - manditory
  38. check_root() {
  39. if [ "$USER" != "root" ]; then
  40.   while true
  41.   do
  42.     echo ""
  43.     echo "You need to be super user to install this software. \c"
  44.     echo ""
  45.     echo "Would you like to continue with the installation? <[y/n] y> \c"
  46.     read ans
  47.      if [ "$ans" = "" ]; then 
  48.     ans="y" 
  49.      fi
  50.  
  51.      case "$ans" in
  52.       y|Y|yes|YES) echo "";echo "Enter super user \c";su root -c 'USER=root;export USER;$COMPANY_DIR/_install/launchit.sh $theARGS';exit 0
  53.             ;;
  54.       N|Q|n|q|No|quit|NO|QUIT|Quit) end_it
  55.             ;;
  56.      esac
  57.   done
  58. fi 
  59. }
  60. # terminate installation
  61. end_it () {
  62.   echo " " 
  63.   echo $1
  64.   echo " " 
  65.   echo "Hit return to end ..."
  66.   echo " "
  67.   read answer
  68.   exit 0 
  69. }
  70. # prompt to remove stuff before terminating 
  71. end_it_rm () {
  72. cd $HOME
  73. echo ""
  74. echo "Remove demo directory $installdir?"
  75.         echo "\n<[y/n] y>\c";read x
  76.         if [ "$x" = "" ];then x="y"
  77.         fi
  78.         if [ $x = "n" -o $x = "no" -o $x = "No" -o $x = "N" ];then
  79.         exit 0
  80.     fi
  81.         if [ $x = "y" -o $x = "yes" -o $x = "Yes" -o $x = "Y" ];then
  82.           rm -rf $installdir
  83.           if [ -d $path ]; then
  84.                 echo ""
  85.                 echo "Could not remove installation directory."
  86.                 echo ""
  87.         end_it
  88.           fi
  89.         else
  90.       end_it_rm
  91.         fi
  92. }
  93.  
  94. # if prompt is required, do so
  95. prompt_choice() {
  96.   echo ""
  97.   echo "Which package from Network Engineering Software would you like to install?\n"
  98.   echo ""
  99.   echo "1) Telaxian Shield firewall server" 
  100.   echo "2) Sky Light web server" 
  101.   echo ""
  102.   echo "3) Exit installation."
  103.   echo ""
  104.   echo "Enter your selection:  \c"
  105.   read answer
  106.  
  107.   case "$answer" in
  108.      1)    WHICHPROD="shield.tar.Z" 
  109.     WHICHPRODNAME="Telaxian Shield" 
  110.         WHICHSCRIPT="NETINST"
  111.     WHICHDIR="install"
  112.     ;;
  113.      2) WHICHPROD="install-www-ssl.tar.Z"
  114.     WHICHPRODNAME="Sky Light" 
  115.         WHICHSCRIPT="webinst"
  116.     WHICHDIR="install-www-ssl"
  117.     ;;
  118.      3) end_it  
  119.     ;;
  120.      *) echo "Please choose one."
  121.     prompt_choice
  122.     ;;
  123.   esac
  124. }
  125. # if choice driven by .demosh script:
  126. auto_choice () {
  127.   case "$1" in
  128.      1) #WHICHPROD=""
  129.         WHICHPRODNAME="Backup Professional"
  130.         install_script="sol_srv"
  131.         ;;
  132.      2) WHICHPROD="NotifyServer"
  133.         WHICHPRODNAME="IPnetWATCHER Notification Server"
  134.         installdir=NotificationServer11woJRE
  135.         ;;
  136.   esac   
  137.  
  138. }
  139. # if system installation is required
  140. prompt_path () {
  141. installdir="$HOME"
  142. echo ""
  143. echo "Please enter an install path to begin installing $WHICHPRODNAME:"
  144.  
  145. echo "\n<$installdir>\c";read path
  146. if [ -n "$path" ]; then
  147. installdir="$path"
  148. fi
  149. verify_path $installdir
  150. }
  151.  
  152. verify_path () {
  153. installdir=$1
  154. if [ ! -d $installdir ]; then
  155.         echo "$installdir does not exist, create it?"
  156.     echo "\n<[y/n] y>\c";read x
  157.     if [ "$x" = "" ];then x="y"
  158.     fi
  159.     if [ $x = "y" -o $x = "yes" -o $x = "Yes" -o $x = "Y" ];then 
  160.           mkdir -p $installdir
  161.           if [ ! -d $installdir ]; then
  162.         echo ""
  163.                 echo "Could not create destination directory."
  164.                 prompt_path 
  165.           fi
  166.     else
  167.       end_it "A destination directory needs to be specified."
  168.     fi
  169. fi
  170. if [ ! -w $installdir ];then
  171.     echo "You can not write to $installdir" 
  172.     prompt_path
  173. fi
  174.  
  175. FREE_SPACE=0
  176. df=/tmp/FREE.$$
  177. /usr/bin/df -k $installdir | sed /kbytes/d | sed -e '3,$d' | sed -e '1,$s/  */ /g' > $df
  178. case `/usr/bin/wc -l $df | sed -e 's/^ *//' | cut -f1 -d" " ` in
  179.         1) FREE_SPACE=`cat $df | cut -f4 -d" "` ;;
  180.         2) FREE_SPACE=`cat $df | sed 1d | sed 's/^ *//' | cut -f3 -d" "` ;;
  181. esac
  182. if [ -n $FREE_SPACE ]
  183. then
  184.         if [ $FREE_SPACE -lt $PRODUCT_SIZE ]
  185.         then
  186.            echo
  187.            echo "The product installation requires $PRODUCT_SIZE kbytes of"
  188.            echo "free disk space. There is only $FREE_SPACE kbytes of free"
  189.            echo "disk space in the selected filesystem.  Please free up some"
  190.            echo "disk space, or choose another directory."
  191.                 prompt_path
  192.         fi
  193. fi
  194. /bin/rm $df 2>/dev/null
  195.  
  196. return 0 
  197. }
  198.  
  199. #*****************
  200. #  end subs
  201. #*****************
  202.  
  203. #Variables
  204. theARGS=$1
  205. PRODUCT_SIZE='1000'
  206. WHICHPROD=
  207. WHICHPRODNAME=
  208. #installdir= $COMPANY_DIR/_install
  209. export PRODUCT_SIZE WHICHPROD WHICHPRODNAME installdir theARGS
  210.  
  211.   echo ""
  212.   echo 
  213.  
  214. ##  Call out Subs here ###
  215.  
  216. check_root
  217. #check_root_maybe
  218. auto_choice $theARGS
  219. #prompt_choice
  220. #prompt_path
  221.  
  222. # below is custom for each demo
  223.  
  224. echo ""
  225. echo "$WHICHPRODNAME installation starting..."
  226. echo ""
  227. echo ""
  228. echo ""
  229. echo "This may take a few minutes..."
  230. echo ""
  231. #mkdir -p $installdir
  232. #cp $COMPANY_DIR/_install/install.zip $installdir
  233. #chmod -R 777 $installdir
  234. cd $COMPANY_DIR/_install
  235. ./$install_script
  236. #unset JAVA_HOME
  237. #unset CLASSPATH
  238. #JAVA_HOME=$CD_MOUNT/products/bin/java/$CDWARE_ENV/bin/
  239. #CLASSPATH=$COMPANY_DIR/_install/bin/dtCoreEngine.jar:$COMPANY_DIR/_install/bin/dtDefPlugins.jar:$COMPANY_DIR/_install/bin/ke31lib.jar:$COMPANY_DIR/_install/bin/pj.jar
  240. #export CLASSPATH
  241. #$CD_MOUNT/products/bin/java2/$CDWARE_ENV/bin/java espial.devicetop.system.DevicetopImpl 
  242. #/tmp/solcd/.cgi-bin/gunzip -c $COMPANY_DIR/_install/$WHICHPROD | tar xvf -
  243.  
  244. #chmod 777 $install_script
  245. #$COMPANY_DIR/_install/unix/solaris/./$install_script
  246. #rm -r $installdir
  247.  
  248. end_it
  249.